package com.shwread.android.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.ciko.code.utils.Util;
import com.mywork.R;
import com.shwread.android.qysw.activity.ApproverActivity;
import com.shwread.android.qysw.activity.MyBusinessTripDetailActivity;

/**
 */
public class ApprovalDommentsDialog extends
        Dialog {
    private Button btnCancel, btnSure;
    private EditText editText;
    private Context context;
    private ApprovalListener approvalListener;
    public ApprovalDommentsDialog(Context context,ApprovalListener approvalListener) {
        super(context, R.style.common_dialog);
        setCanceledOnTouchOutside(true);
        this.context = context;
        this.approvalListener=approvalListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_approver_domments);
        initView();
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (getEidtText().length() > 100) {
                    Util.showToast(context, "字数超过100字");
                    return;
                }else {
                    Toast.makeText(context,"提交成功",Toast.LENGTH_SHORT).show();
                }
                approvalListener.clickOk();

                ApprovalDommentsDialog.this.dismiss();
                ((MyBusinessTripDetailActivity)context).finish();

            }
        });

        btnSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (getEidtText().length() > 100) {
                    Util.showToast(context, "字数超过100字");
                    return;
                }else {
//                    Toast.makeText(context,"提交成功",Toast.LENGTH_SHORT).show();
                }
                approvalListener.clickNext();
                Intent intent = new Intent(context,ApproverActivity.class);
                context.startActivity(intent);
                ApprovalDommentsDialog.this.dismiss();
            }
        });

    }

    private void initView() {
        btnCancel = (Button) findViewById(R.id.btn_cancel);
        btnSure = (Button) findViewById(R.id.btn_sure);
        editText = (EditText) findViewById(R.id.res_et);
    }

    public String getEidtText() {
        String str = "";
        str = editText.getText().toString();

        return str;
    }
}
